import { getCookies, removeCookie } from '../../utils/index';

export default {
    namespaced: true,
    state: () => ({

    }),
    mutations: {

    },
    actions: {
        getUserInfo: ({ commit }) => {
            let userInfo = getCookies('userInfo');
            let noLogin = {
                userInfo: {
                    icon: '',
                },
                isLogin: false,
            }
            if (!userInfo) {
                return noLogin;
            }
            try {
                userInfo = JSON.parse(userInfo);
                if(!(Object.prototype.toString.call(userInfo) === '[object Object]')){
                    return noLogin;
                }
                return {
                    userInfo,
                    isLogin: true,
                };
            } catch (e) {
                return noLogin;
            }

        },
    }
}